package com.ruoyi.utils;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

/**
 * @author chenjc
 * @since 2020/12/25 9:03
 */
public class ParamsDictUtil {

    /**
     * 图片查看路径
     */
    public static final String PRODUCT_PATH = "http://";

    /**
     * 图片上传路径
     */
    public static final String PRODUCT_UPLOAD_PATH = "/data/hh-erp/images";

    /**
     * 师傅角色
     */
    public static final Long ROLE_WORKER = 101L;
    /**
     * 客户角色
     */
    public static final Long ROLE_USER = 102L;
    /**
     * 无师傅
     */
    public static final Long DEFAULT_WORKER = 88L;
    /**
     * 默认密码
     */
    public static final String DEFAULT_PASSWORD = "123456";
    /**
     * 未删除
     */
    public static final String IS_NOT_DEL = "0";
    /**
     * 未打印 状态码
     */
    public static final String ORDER_STATUS_EDIT = "0";
    /**
     * 已打印 状态码
     */
    public static final String ORDER_STATUS_PRINT = "1";
    /**
     * 已结算 状态码
     */
    public static final String ORDER_STATUS_CLOSE = "2";
    /**
     * 未结清 状态码
     */
    public static final String ORDER_STATUS_NO_CLEAR = "3";
    /**
     * 已结清 状态码
     */
    public static final String ORDER_STATUS_CLEAR = "4";
    /**
     * 未付清 状态码
     */
    public static final String CLOSE_SALE_NO_PAY = "0";
    /**
     * 已付清 状态码
     */
    public static final String CLOSE_SALE_PAY = "1";
    /**
     * 欠款减少
     */
    public static final String ACCOUNT_REDUCE = "11";
    /**
     * 欠款增加
     */
    public static final String ACCOUNT_INCREASE = "12";
    /**
     * 付款
     */
    public static final String PAY_TYPE_PAY = "1";
    /**
     * 单笔付清 付款关键字
     */
    public static final String PAY_TYPE_ORDER = "2";
    /**
     * 付清 付款关键字
     */
    public static final String PAY_TYPE_CLEAR = "3";
    /**
     * 结算 付款关键字
     */
    public static final String PAY_TYPE_RETURN = "4";
    /**
     * 销售单
     */
    public static final String ORDER_TYPE_SALE = "1";
    /**
     * 结算单
     */
    public static final String ORDER_TYPE_CLOSE = "2";
    /**
     * 退货单
     */
    public static final String ORDER_TYPE_RETURN = "3";
    /**
     * 销售单和退货单
     */
    public static final String ORDER_TYPE_SR = "99";
    /**
     * 付款记录关键字
     */
    public static final String REMARK_CLOSE_PAY = "结算付款";
    /**
     * 结算记录关键字
     */
    public static final String REMARK_PAY_RETURN_CLOSE = "退货结算";
    /**
     * 付款记录关键字
     */
    public static final String REMARK_PAY_NO_PRINT = "暂付未打印";
    /**
     * 付款记录打印关键字
     */
    public static final String REMARK_PAY_PRINT = "暂付打印";
    /**
     * 付款记录结算打印关键字
     */
    public static final String REMARK_PAY_PRINT_END = "结算，暂付清空";
    /**
     * 金额正则 “-12.23”
     */
    public static final String MONEY_REGEX = "[+-]?[0-9]+(\\.[0-9]{1,2})?";

    public static final String IMPORT_NOT_TYPE = "导入数据分类不正确！";

    public static boolean isPositive(BigDecimal number) {
        int result = number.compareTo(BigDecimal.ZERO);
        return result > 0;
    }

    public static String changePrice(String price) {
        if (StringUtils.isNotBlank(price)) {
            price = new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
        }
        return price;
    }
}
